//
//  SClass.m
//  SimulacraDB
//
//  Created by Andre Cohen on 9/10/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "SClass.h"
#import "DataSourceBTree.h"
#import "RecordFactory.h"

@implementation SClass

- (id)init {
	[super init];
	
	Record *prototype = [RecordFactory createClassRecord:nil withParent:nil inNamespace:nil];
	source = [[[DataSourceBTree alloc] initWithDataSource:@"class" recordPrototype:prototype] autorelease];
	
	[source addIndexWithName:@"namespace" block:0];
	[source addIndexWithName:@"parent" block:1];
	[source addIndexWithName:@"name" block:2];
	
	return self;
}

- (NSArray *)getClassInNamespace:(Record *)ns 
						withName:(NSString *)name {
	return nil;
}
- (Record *)createClassInNamespace:(Record *)ns
						withParent:(Record *)parent
						  withName:(NSString *)name {
	
	Record *r = [RecordFactory createClassRecord:name 
									  withParent:[[parent wrapper] rid] 
									 inNamespace:[[ns wrapper] rid]];

	[source insertRecord:r];
	
	return r;
}


@end
